import 'package:flutter/material.dart';

import 'HttpConfig/http.dart';
//import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';

class NewDetailsPage extends StatefulWidget {

  final Map<String,dynamic> arguments;
  NewDetailsPage({Key key,@required this.arguments}) : super(key: key);

  @override
  _NewDetailsPageState createState() => _NewDetailsPageState(this.arguments["aid"]);
}

class _NewDetailsPageState extends State<NewDetailsPage> {
  var code;
  bool flag = true;
  //List _list = new List();
  _NewDetailsPageState(this.code) :super();
  @override
  void initState() {
    super.initState();
    // ResustHttp.getNewDetails(this.code).then((value){
    //   print(value);
    //   setState(() {
    //     this._list = value["result"];
    //   });
    // });
  }

  Widget Londing() {
   return Container(
          padding: EdgeInsets.symmetric(vertical: 20),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                '努力加载中...',
                style: TextStyle(
                  fontSize: 15,
                  color: Color(0xFF333333),
                ),
              ),
              Padding(padding: EdgeInsets.only(left: 10)),
              SizedBox(
                width: 20,
                height: 20,
                child: CircularProgressIndicator(strokeWidth: 3),
              ),
            ],
          ),
        );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("详情"),
      ),
      body:
      Column(
        children: <Widget>[
          this.flag ? Londing() : Text(""),
          Expanded(
            child:InAppWebView(
              initialUrl: "https://blog.csdn.net/luck_yangl/article/details/101532999",
              onProgressChanged: (InAppWebViewController conteoller,int progress){
                print(progress);
                if((progress/100) > 0.9){
                  setState(() {
                    this.flag = false;
                  });
                }
              },
            )
          )
        ],
      )
    );
  }
}


//  ListView(
//         children: <Widget>[
//          Html(
//             data: """
//              ${_list[0]["content"]}
//             """,
//             //Optional parameters:
//             padding: EdgeInsets.all(8.0),
//             backgroundColor: Colors.white70,
//             defaultTextStyle: TextStyle(fontFamily: 'serif'),
//             linkStyle: const TextStyle(
//               color: Colors.redAccent,
//             ),
//             onLinkTap: (url) {
//               // open url in a webview
//             },
//           )
//         ],
//       ) : Center(
//         child: CircularProgressIndicator(
//             semanticsLabel: "加载中...",
//         ),
//       )
